// refer to  https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/toolkit/

namespace go user_manager
namespace py user_manager
namespace java user_manager

enum Code {
     Success         = 1
     ParamInvalid    = 2
     DBErr           = 3
}

struct User {
    1: string nick_name
    2: string avatar_url
    3: string user_id
}

struct LoginUserRequest{
    1: string code      (api.query="code",api.vd="(len($) > 0 && len($) < 100)")
}

struct LoginUserResponse{
   1: Code code
   2: User user_info
}

struct UpdateUserRequest{
    1: string nick_name (api.body="nick_name", api.form="nick_name",api.vd="(len($) >= 0 && len($) < 100)")
    2: string avatar_url (api.body="avatar_url", api.form="avatar_url",api.vd="(len($) >= 0 && len($) < 500)")
}

struct UpdateUserResponse{
   1: Code code
   2: string msg
}

struct GetUserInfoRequest{}

struct GetUserInfoResponse{
   1: Code code
   2: User user_info
}

service UserService {
   // 用户登录
   LoginUserResponse UserLogin(1:LoginUserRequest req)(api.get="/api/user/login")
   // 更新用户信息
   UpdateUserResponse UpdateUser(1:UpdateUserRequest req)(api.post="/api/user/update")
   // 获取用户信息
   GetUserInfoResponse GetUserInfo(1:GetUserInfoRequest req)(api.get="/api/user/info")
}


enum FileOption {
    UnKnown= 0
    View = 1
    Download = 2
}

enum FileTaskType {
    UnKnown = 0
    PDF_WORD = 1
    PDF_EXCEL = 2
    WORD_PDF = 3
    EXCEL_PDF = 4
}

enum FileTaskStatus {
    UnKnown = 0
    Running = 1
    Success = 2
    Failed = 3
}

struct File {
    1: string file_id (api.body="file_id")
    2: string file_name (api.body="file_name")
    // 文件access_key
    3: string file_url (api.body="file_url")
    4: string file_type (api.body="file_type")
    5: i64 file_size (api.body="file_size")
}

struct FileTask {
    1: string task_id (api.body="task_id")
    2: FileTaskType task_type (api.body="task_type")
    3: FileTaskStatus task_status (api.body="task_status")
    4: list<File> source_file (api.body="source_file")
    5: list<File> target_file (api.body="target_file")
    6: string task_name (api.body="task_name")
    7: string create_time (api.body="create_time")
    8: string update_time (api.body="update_time")
}

struct GetFileUrlRequest {
    1: string access_key (api.query="access_key",api.vd="(len($) > 0 && len($) < 100)")
    2: FileOption option (api.query="option")
}

struct SubmitFileTaskRequest {
    1: FileTask file_task (api.body="file_task")
}

struct GetFileTaskListRequest {
    // 游标查询起始位置
    1: string cursor (api.query="cursor"  api.vd="(len($) >= 0)")
    // 查询数量
    2: i32 limit (api.query="limit" api.vd="($ > 0 && $ <= 20)")
}

struct GetFileTaskDetailRequest {
    // 任务id
    1: string task_id (api.query="task_id")
}

struct CheckFileTaskStatusRequest {
    // 任务id
    1: string task_id (api.query="task_id")
}

struct GetUploadSignResponse {
    1: Code code
    2: string secret_id
    3: string secret_key
    4: string token
    5: i64 expired_time
    6: i64 start_time
}

struct GetFileUrlResponse {
    1: Code code
    2: string file_url
}

struct SubmitFileTaskResponse {
    1: Code code
    2: string task_id
}

struct GetFileTaskListResponse {
    1: Code code
    2: list<FileTask> file_task_list
    3: string next_cursor
}

struct GetFileTaskDetailResponse {
    1: Code code
    2: FileTask file_task
}

struct CheckFileTaskStatusResponse {
    1: Code code
    2: FileTaskStatus task_status
}

service FileService {
    // 获取文件上传临时密钥
    GetUploadSignResponse GetUploadSign()(api.get="/api/file/upload/sign")
    // 获取文件预签名url
    GetFileUrlResponse GetFileUrl(1:GetFileUrlRequest req)(api.get="/api/file/url")
    // 提交文件解析任务
    SubmitFileTaskResponse SubmitFileTask(1:SubmitFileTaskRequest req)(api.post="/api/file/task/submit")
    // 获取文件解析任务列表
    GetFileTaskListResponse GetFileTaskList(1:GetFileTaskListRequest req)(api.get="/api/file/task/list")
    // 获取文件解析任务详情
    GetFileTaskDetailResponse GetFileTaskDetail(1:GetFileTaskDetailRequest req)(api.get="/api/file/task/detail")
    // 检查文件解析任务状态
    CheckFileTaskStatusResponse CheckFileTaskStatus(1:CheckFileTaskStatusRequest req)(api.get="/api/file/task/check")
}
